package com.docker.manege.image;

import com.docker.core.constant.APPIDConstant;
import com.docker.core.mvc.APPID;
import com.docker.core.mvc.Remark;
import com.docker.core.mvc.controller.BaseAPIController;
import com.jfinal.aop.Inject;

/**
 * @Author ldl
 * @Create 2020/12/02 002 14:56
 */
@Remark("镜像管理")
@APPID(APPIDConstant.dum_web)
public class ImagesController extends BaseAPIController {

    @Inject
    private ImagesService imagesService;

    @Remark("获取镜像列表")
    public void list() {
        renderAPISuccess(imagesService.list(getClientKey(), getPara("image_tags")));
    }

    /**
     * @Param: []
     * @return: TODO
     * @Author: ldl
     * @Create: 2021/01/13 013 09:26
     */
    @Remark("搜索镜像")
    public void search() {
        renderAPISuccess(imagesService.search(getClientKey(), getPara("image_name")));
    }

    /**
     * @Param: []
     * @return: TODO
     * @Author: ldl
     * @Create: 2021/01/13 013 09:28
     */
    @Remark("拉取镜像")
    public void pull() {
        renderAPI(imagesService.pull(getClientKey(), getPara("connect_key"), getBean(ImagesBean.class, ""), getUserId()));
    }

    /**
     * @Param: []
     * @return: TODO
     * @Author: ldl
     * @Create: 2021/01/13 013 10:52
     */
    @Remark("删除镜像")
    public void remove() {
        renderAPI(imagesService.remove(getClientKey(), getPara("server_id"), getPara("image_id"), getPara("image_name"), "0", getUserId()));
    }

    /**
     * @Param: []
     * @return: TODO
     * @Author: ldl
     * @Create: 2021/01/17 017 01:55
     */
    @Remark("删除镜像[强制]")
    public void fremove() {
        renderAPI(imagesService.remove(getClientKey(), getPara("server_id"), getPara("image_id"), getPara("image_name"), "1", getUserId()));
    }

    /**
     * @Param: []
     * @return: TODO
     * @Author: ldl
     * @Create: 2021/01/13 013 11:57
     */
    @Remark("详情")
    public void detail() {
        renderAPISuccess(imagesService.detail(getPara("server_id"), getPara("image_name")));
    }

}
